<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<div class="form-horizontal" role="form" >
   <input type="hidden" id="token" name="token" value="<%=request.getAttribute("token") %>" />
    <input id="id" value="${merchant.id}"  type="hidden"/>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">商家名称:</label>
        <div class="col-md-9">
        	 <input id="name" value="${merchant.name}" data-check="require:true;code:^[a-zA-Z0-9\u4e00-\u9fa5]{,30};message:不能为空" type="text" placeholder="商家名称" class="form-control" name="name"/>
        </div>
    </div>
<!-- 	<div class="form-group"> -->
<!--  	    <label class="col-md-3 col-sm-3 control-label">状态:</label> -->
<!--         <div class="col-md-9"> -->
<!--         	 <select id="status" data-placeholder="选择状态" class="chosen-select full-width"  tabindex="2"> -->
<!--         	 <option value="0">正常</option> -->
<!--         	 <option value="1">待审核</option> -->
<!--         	 <option value="2">已拒绝</option> -->
<!--         	 <option value="3">已锁定</option> -->
<!-- 			</select> -->
<!--         </div> -->
<!--     </div> -->
    	<div class="form-group">
	 	    <label class="col-md-3 col-sm-3 control-label">图片:</label>
	        <div class="col-md-9">
	        	 <div class="col-md-10">
		        	 <input class="fileInput" id="imageUploadify" type="file" name="file"  accept="image/*"/>
		        	 <div class="imageUploadify">   
						<c:if test="${not empty(merchant.logo)}">
						<c:forEach items="${fn:split(merchant.logo,',')}" var="i">
							<img src="${i}" style="width: 60px;height: 60px">
						</c:forEach>
						</c:if>
					 </div>
		        </div>
	        </div>
	    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">联系方式:</label>
        <div class="col-md-9">
        	 <input id="mobile" value="${merchant.mobile}"  type="text" placeholder="联系方式" class="form-control" name="mobile"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">地址:</label>
        <div class="col-md-9">
        	 <input id="address" value="${merchant.address}"  type="text" placeholder="地址" class="form-control" name="address"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">商家简介:</label>
        <div class="col-md-9">
        	 <textarea id="description" value="${merchant.description}"  type="text" placeholder="商家简介" class="form-control" name="description"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">特色优势:</label>
        <div class="col-md-9">
        	 <textarea id="advantage" value="${merchant.advantage}"  type="text" placeholder="特色优势" class="form-control" name="advantage"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">商家资质:</label>
        <div class="col-md-9">
        	 <input id="license" value="${merchant.license}"  type="text" placeholder="商家资质" class="form-control" name="license"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">企业类型:</label>
        <div class="col-md-9">
             <select id="typeId" data-placeholder="选择企业类型" class="chosen-select full-width"  tabindex="4">
			</select>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">特色优势:</label>
        <div class="col-md-9">
        	 <script type="text/plain" id="editor"></script>
        </div>
    </div>
</div>

<script>
$(function(){
	$("#typeId").chosen({ width: '100%' });
	$("#status").chosen({ width: '100%' });
    $.ajax({  
		url:'${ctx}/merchantType/list',  		 					
		type: 'POST',
		dataType:'json',  
		success:function(response){
			if(response.code==0){
				var html=[];
				var data=response.data||[];
				for(var i=0;i<data.length;i++){
					html.push('<option value="'+data[i].id+'">'+data[i].name+'</option>');
				}
				$("#typeId").append(html.join(""));
				$("#typeId").trigger("chosen:updated");
			}
		 }  
     });
}); 
$("#imageUploadify").uploadify({
	'buttonImage':'${ctx}/static/js/plugins/uploadify/uploadify-button.png',
    'swf': '${ctx}/static/js/plugins/uploadify/uploadify.swf',
    'uploader':'${ctx}/file/uploadOss',
    "multi":false,
    'onFallback' : function() {//检测FLASH失败调用 
    	alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");  
    },  
    'onUploadSuccess':function(file, data, response){
    	var jData = jQuery.parseJSON(data);
        $(".imageUploadify").html("<img src=\""+jData.data+"\" style=\"width: 60px;height: 60px;padding-left:5px;\">");
	}
});
</script>